package com.carlinfo.back.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 登陆后的首页
 * @author WangshMac
 */
public class AdminsBackServlet extends HttpServlet
{
	private Logger logger = LogManager.getLogger() ; 
	
	@Override
	protected void service(HttpServletRequest request, 
			HttpServletResponse response) throws ServletException, IOException
	{
		logger.info("==AdminsBackServlet=service==");
		/* 	取信的内容;取单个
		 *  */
		String method = request.getParameter("method");
		logger.info("==method:{}==",method);
		
		if("main".equalsIgnoreCase(method))
		{
			/* 	首页 	*/
			this.main(request,response);
		}else if("welcome".equalsIgnoreCase(method))
		{
			/*	 欢迎页面 	*/
			this.welcome(request,response);
		}
	}
	
	/**
	 * 	欢迎页面
	 * @throws IOException 
	 * @throws ServletException 
	 */
	private void welcome(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		logger.info("==welcome==");
		/*	 打开登陆页	 */
		String path = "/WEB-INF/jsp/back/admins/welcome.jsp";
		/*	 服务器端跳转	 */
		request.getRequestDispatcher(path).forward(request, response);
	}

	/**
	 * 	 登陆后的首页
	 * @throws IOException 
	 * @throws ServletException 
	 */
	private void main(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		logger.info("==main==");
		/*	 打开登陆页	 */
		String path = "/WEB-INF/jsp/back/admins/main.jsp";
		/*	 服务器端跳转	 */
		request.getRequestDispatcher(path).forward(request, response);
	}
}
